package com.xiaoxu.intranetweb.mybatisplusSzappdb.controller.gps;


import com.alibaba.fastjson.JSONObject;
import com.xiaoxu.intranetweb.mybatisplusSzappdb.business.gps.GpsBU;
import com.xiaoxu.intranetweb.mybatisplusSzappdb.service.impl.Gps18TruckOverspeedServiceImpl;
import com.xiaoxu.intranetweb.util.SzResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lvNuo
 * @since 2025-04-03
 */
@RestController
@RequestMapping("/gps18TruckOverspeed")
public class Gps18TruckOverspeedController {
    @Autowired
    private Gps18TruckOverspeedServiceImpl gps18TruckOverspeedService;
    @Autowired
    private GpsBU gpsBU;

    @GetMapping("/gps18TruckOverspeedList")
    public SzResult gps18TruckOverspeedList(@RequestParam(value = "page", required = false) Integer page,
                                                @RequestParam(value = "pageSize", required = false) Integer pageSize,
                                                @RequestParam(value = "truckNo", required = false) String truckNo,
                                                @RequestParam(value = "startTime", required = false) String startTime,
                                                @RequestParam(value = "endTime", required = false) String endTime){
        return gps18TruckOverspeedService.getList(page,pageSize,truckNo,startTime,endTime);
    }

    @GetMapping("/getTruckOverspeedList")
    public SzResult getTruckOverspeedList(@RequestParam(value = "bindId", required = false) String bindId){

        return gps18TruckOverspeedService.getTruckOverspeedList(bindId);
    }
//    设置超速报警速度
    @PostMapping("/setOverSpeedThreshold")
    public SzResult setOverSpeedThreshold(
            @RequestBody JSONObject jsonObject,
                                          HttpServletRequest request){
        String token = request.getHeader("Authorization");
        String plantId = request.getHeader("Plant-Id");
        String overSpeed = jsonObject.getString("overSpeed");
        return gpsBU.setOverSpeedThreshold(overSpeed,plantId);
    }
//    查询超速报警速度
    @GetMapping ("/getOverSpeedThreshold")
    public SzResult getOverSpeedThreshold(

            HttpServletRequest request ){
        String plantId = request.getHeader("Plant-Id");
        return gpsBU.getOverSpeedThreshold(plantId);
    }
}
